//
//  PeopleCollectionViewCell.m
//  QT
//
//  Created by 甘世清 on 2025/1/1.
//

#import "PeopleCollectionViewCell.h"

@implementation PeopleCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    [self.contentView addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
  
    UIImageView * bgImage = [[UIImageView alloc]init];
    bgImage.image = SQGetImage(@"阴影");
    bgImage.contentMode = UIViewContentModeScaleAspectFill;
    bgImage.clipsToBounds = YES;
    [self.headerView addSubview:bgImage];
    [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.equalTo(self.headerView);
            make.height.mas_equalTo(50);
    }];
    
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(14);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-30);
        make.height.mas_equalTo(14);
    }];
    
    [self.contentView addSubview:self.messageLabel];
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
        make.height.mas_equalTo(20);
    }];
    
    
    [self.contentView addSubview:self.genderImage];
    [self.genderImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(16);
        make.left.equalTo(self.nameLabel.mas_right).offset(5);
        make.bottom.equalTo(self.nameLabel.mas_bottom);
    }];
 
    [self.contentView addSubview:self.cityLabel];
    [self.cityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(70);
            make.height.mas_equalTo(26);
            make.top.equalTo(self.contentView).offset(10);
            make.right.equalTo(self.contentView.mas_right).offset(-10);
    }];
}
- (void)setModel:(PictureModel *)model{
    _model = model;
    [self.headerView sd_setImageWithURL:SQURLImage(model.portrait) placeholderImage:SQGetImage(@"2")];
    self.nameLabel.text = model.name;
    if (model.gender  == 1) {
        self.genderImage.image = SQGetImage(@"男");
    } else {
        self.genderImage.image = SQGetImage(@"女");
    }
    self.cityLabel.text = @"成都";
    self.messageLabel.text = SQNSLocalString(@"这个人有点懒..");
 
}
- (UILabel *)cityLabel{
    if (!_cityLabel) {
        _cityLabel = [[UILabel alloc]init];
        _cityLabel.font = FONT_REGULAR(10);
        _cityLabel.textAlignment = NSTextAlignmentCenter;
        _cityLabel.textColor = UIColor.whiteColor;
        _cityLabel.backgroundColor = SQHexColor(@"#000000", 0.4);
        _cityLabel.adjustsFontSizeToFitWidth = YES;
        _cityLabel.layer.cornerRadius = 13;
        _cityLabel.layer.masksToBounds = YES;
    }
    return _cityLabel;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(16);
        _nameLabel.textColor = UIColor.whiteColor;
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.numberOfLines = 0;
    }
    return _nameLabel;
}

- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_MEDIUM(12);
        _messageLabel.textColor = UIColor.whiteColor;
        _messageLabel.backgroundColor = UIColor.clearColor;
    }
    return _messageLabel;
}
 
- (UIImageView *)headerView{
    if (!_headerView) {
        _headerView = [[UIImageView alloc]init];
        _headerView.contentMode = UIViewContentModeScaleAspectFill;
        _headerView.clipsToBounds = YES;
        _headerView.layer.cornerRadius = 10;
        _headerView.layer.masksToBounds = YES;
    }
    return _headerView;
}

- (UIImageView *)genderImage{
    if (!_genderImage) {
        _genderImage = [[UIImageView alloc]init];
        _genderImage.image = SQGetImage(@"女");
    }
    return _genderImage;
}
- (UIImageView *)vipImage{
    if (!_vipImage) {
        _vipImage = [[UIImageView alloc]init];
        _vipImage.image = SQGetImage(@"huiyuanquanyi");
    }
    return _vipImage;
}
- (UIImageView *)realStatusImage{
    if (!_realStatusImage) {
        _realStatusImage = [[UIImageView alloc]init];
        _realStatusImage.image = SQGetImage(@"unrenzheng");
    }
    return _realStatusImage;
}

@end
